<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>密码策略编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <style>
        .layui-input,.layui-textarea {
            display: inline;
            width: 55%;
        }
        .layui-form-label {
            width: 25%;
        }
        .layui-input-block {
            margin-left: 30%;
        }
    </style>
</head>
<body>
<script type="text/html" template>
<form class="layui-form"  requrl="{{ serverPath.systemPath + layui.setter.sysLinkPath}}pwdStrategy/get" style="padding: 0px 5px;margin-left: auto;margin-right: auto" lay-filter="sysPwdStrategyDataForm">

    <div style="margin: 15px 0px; height:467px;overflow-y: auto;">
        <div class="layui-form-item" style="display:none;">
            <label class="layui-form-label">id</label>
            <div class="layui-input-block">
                <input type="text" name="id"  placeholder="请输入id"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="id">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">初始化密码</label>
            <div class="layui-input-block">
                <input type="text" name="initPwd"  placeholder="请输入初始化密码"
                       autocomplete="off" class="layui-input " lay-verify="pass" maxlength="50" fieldname="initPwd">
                <span>(不填则为没有初始化密码)</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">强制修改初始化密码</label>
            <div class="layui-input-block">
                <input type="radio" name="forceChangeInitPwd" value="0" title="否" checked>
                <input type="radio" name="forceChangeInitPwd" value="1" title="是">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码规则</label>
            <div class="layui-input-block">
                <input type="radio" name="pwdRule" value="0" title="无限制" checked>
                <input type="radio" name="pwdRule" value="1" title="数字加字母">
                <input type="radio" name="pwdRule" value="2" title="数字加字母加特殊字符">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码长度</label>
            <div class="layui-input-block">
                <input type="text" name="pwdLength"  placeholder="请输入密码长度"
                       autocomplete="off" class="layui-input" lay-verify="required|number" maxlength="50" fieldname="pwdLength" value="0">
                <span>(0代表无限制)</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码过期处理</label>
            <div class="layui-input-block">
                <input type="radio" lay-filter="handleOverdue" name="handleOverdue" value="0" title="不处理" checked>
                <input type="radio" lay-filter="handleOverdue" name="handleOverdue" value="1" title="强制修改">
            </div>
        </div>
        <div class="layui-form-item" style="display: none">
            <label class="layui-form-label">密码过期提醒</label>
            <div class="layui-input-block">
                <input type="text" name="overdueRemind"  placeholder="请输入密码过期提醒"
                       autocomplete="off" class="layui-input " lay-verify="required|number" maxlength="50" fieldname="overdueRemind" value="0">
                <span>个星期(0代表不提醒)</span>
            </div>
        </div>
        <div class="layui-form-item condition-display" style="display: none">
            <label class="layui-form-label">密码有效期</label>
            <div class="layui-input-block">
                <input type="text" name="validity"  placeholder="请输入密码有效期"
                       autocomplete="off" class="layui-input" lay-verify="required|number" maxlength="50" fieldname="pwdLength" value="0">
                <span>个月 (0代表无限期)</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码输错多少次出现验证码</label>
            <div class="layui-input-block">
                <input type="text" name="verifyCodeAppear"  placeholder="请输入错误次数"
                       autocomplete="off" class="layui-input " lay-verify="required|number" maxlength="50" fieldname="verifyCodeAppear" value="0">
                <span>次 (0代表不出现)</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码错误多少次锁住账号</label>
            <div class="layui-input-block">
                <input type="text" name="errLockAccount"  placeholder="请输入错误次数"
                       autocomplete="off" class="layui-input " lay-verify="required|number" maxlength="50" fieldname="errLockAccount" value="0">
                <span>次 (0代表不出现)</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用规则</label>
            <div class="layui-input-block">
                <input type="radio" name="enable" value="1" title="启用" checked>
                <input type="radio" name="enable" value="0" title="禁用">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea type="text" name="desc"  placeholder="请输入描述"
                       autocomplete="off" class="layui-textarea " maxlength="500" fieldname="desc">
                </textarea>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div style="text-align: center;">
            <a lay-submit lay-filter="sysPwdStrategy" class="layui-btn btn-n" requrl="{{serverPath.systemPath + layui.setter.sysLinkPath}}pwdStrategy/add">提交</a>
            <button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn btn-n layui-btn-danger btn-save">取消</button>
        </div>
    </div>
</form>
</script>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>

    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','common','laydate','jquery','commons','form','layer'], function () {
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var form = layui.form;
        var commons = layui.commons;
        var layer = layui.layer;
        var dateTimeFiledLen = $(".dateTimeFiled");
        for(var i=0;i<dateTimeFiledLen.length;i++){
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                ,type: 'date'
                ,trigger: 'click'
            });
        }

        form.on('radio(handleOverdue)', function(data){
            if(data.value == 0){
                $(".condition-display").css("display", "none");
            } else {
                $(".condition-display").css("display", "block");
            }
            form.render();
        });

        setTimeout(function () {
            if('${id}'){
                var value = $('input[name=handleOverdue]:checked').val();
                if(value == 0 ){
                    $(".condition-display").css("display", "none");
                }else{
                    $(".condition-display").css("display", "block");
                }
            }
        },1000);


        //关闭当前页面
        $("#closeWindow").click(function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });

        var runId = "${runId}";
        if(runId == null || runId == ''){
            $("#hideAndShow").show();
        }

        var common = layui.common;
        var index = parent.layer.getFrameIndex(window.name);
        common.updateForm({
            name:'sysPwdStrategyDataForm',
            idValue:"${id}",
            primary:"id",
            updateCallback:function (data) {
                if (common.filterRecord(data)) {
                    layer.alert(data.msg, function (index) {
                        layer.close(index);
                        parent.layui.table.reload('sysPwdStrategyTable');
                        parent.layui.totalFilter.init('sysPwdStrategyTable');
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    });
                } else {
                    layer.alert(data.msg);
                }
                return false;
            }
        });
    });
</script>
</body>
</html>